import { defineConfig } from 'vitepress'
import vueJsx from '@vitejs/plugin-vue-jsx'
import plugin from './plugin'
import { resolve } from 'path'

// https://vitepress.dev/reference/site-config
export default defineConfig({
  // title: "",
  description: "基于vue3 + element-plus 的后台管理系统 组件库",
  head: [['link', { rel: 'icon', href: '/favicon.ico' }]],
  base: '/xyAdmin/docs',
  themeConfig: {
    outline: 'deep',
    lastUpdated: {
      formatOptions: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric',
        second: 'numeric',
      },
      text: '更新时间',
    },
    logo: '/logo/home.svg',
    siteTitle: false,
    nav: [
      { text: '首页', link: '/' },
      { text: '后台', link: '/admin/', activeMatch: '/admin/' },
      { text: '组件', link: '/elecomponents/jieshao', activeMatch: '/elecomponents/' },
      {
        text: '项目地址',
        link: 'https://gitee.com/SeaHappy0501/xy-admin',
        target: '_blank',
        rel: 'sponsored'
      }
    ],
    sidebar: {
      '/admin/': [
        {
          text: '后台',
          items: [
            { text: '哈哈哈', link: '/admin/index' },
          ]
        }
      ],
      '/elecomponents/': [
        {
          text: '介绍',
          link: '/elecomponents/jieshao',
        },
        {
          text: '安装、基本要求',
          link: '/elecomponents/installation-requirements',
        },
        {
          text: '全局配置',
          link: '/elecomponents/global-configuration',
        },
        {
          text: '表单组件',
          items: [
            {
              text: '基础表单元素',
              link: '/elecomponents/form/base/index.md',
              items: [
                { text: '标题', link: '/elecomponents/form/base/title/index.md' },
                { text: '输入框', link: '/elecomponents/form/base/input/index.md' },
                { text: '标签输入框', link: '/elecomponents/form/base/inputTag/index.md' },
                { text: '数字输入框', link: '/elecomponents/form/base/inputNumber/index.md' },
                { text: '选择器', link: '/elecomponents/form/base/select/index.md' },
                { text: '日期时间选择器', link: '/elecomponents/form/base/date/index.md' },
                { text: '多选框', link: '/elecomponents/form/base/checkbox/index.md' },
                { text: '单选框', link: '/elecomponents/form/base/radio/index.md' },
                { text: '开关', link: '/elecomponents/form/base/switch/index.md' },
                { text: '级联选择器', link: '/elecomponents/form/base/cascader/index.md' },
                { text: '时间选择器', link: '/elecomponents/form/base/time/index.md' },
                { text: '树形选择', link: '/elecomponents/form/base/treeSelect/index.md' },
                { text: '文件上传', link: '/elecomponents/form/base/upload/index.md' },
                { text: '插槽', link: '/elecomponents/form/base/slot/index.md' },
                { text: '步骤条', link: '/elecomponents/form/base/steps/index.md' },
              ]
            },
            {
              text: '添加表单',
              link: '/elecomponents/form/add/index.md',
              items: [
                { text: '布局', link: '/elecomponents/form/add/layout/index.md' },
              ]
            },
            {
              text: '搜索表单',
              link: '/elecomponents/form/search/index.md'
            }
          ]
        },
        {
          text: '表格组件',
          items: [
            {
              text: '基础表格元素',
              link: '/elecomponents/table/base/index.md',
              items: [
                { text: '普通列（排序、筛选、合并）', link: '/elecomponents/table/base/default/index.md' },
                { text: '编辑列（输入框、下拉等）', link: '/elecomponents/table/base/edit/index.md' },
                { text: '操作列', link: '/elecomponents/table/base/oper/index.md' },
                { text: '其他列（展开、单多选等）', link: '/elecomponents/table/base/other/index.md' },
                { text: '顶部操作按钮', link: '/elecomponents/table/base/top/index.md' },
              ]
            },
            {
              text: '列表',
              link: '/elecomponents/table/example/index.md'
            }
          ]
        }
      ],
    },

    socialLinks: [
      { icon: 'gitee', link: 'https://gitee.com/SeaHappy0501/xy-admin' }
    ],

    footer: {
      message: 'Released under the <a href="https://github.com/vuejs/vitepress/blob/main/LICENSE">MIT License</a>.',
      copyright: 'Copyright © 2019-present'
    },

    editLink: {
      pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
      text: '文件链接'
    },

    docFooter: {
      prev: '上一页',
      next: '下一页'
    },

    search: {
      provider: 'local',
      options: {
        locales: {
          root: {
            translations: {
              button: {
                buttonText: '搜索文档',
                buttonAriaLabel: '搜索文档'
              },
              modal: {
                noResultsText: '无法找到相关结果',
                resetButtonTitle: '清除查询条件',
                footer: {
                  selectText: '选择',
                  navigateText: '切换',
                  closeText: '关闭'
                }
              }
            }
          }
        }
      }
    },

    externalLinkIcon: true

    // https://vitejs.cn/vitepress/reference/default-theme-carbon-ads
    // carbonAds: {
    //   code: 'your-carbon-code',
    //   placement: 'your-carbon-placement'
    // }

    // //https://vitejs.cn/vitepress/reference/default-theme-config#lastupdated
    // lastUpdated: {
    //   text: 'Updated at',
    //   formatOptions: {
    //     dateStyle: 'full',
    //     timeStyle: 'medium'
    //   }
    // }
  },
  vite: {
    server: {
      port: 5174,
      host: '0.0.0.0',
    },
    plugins: [
      vueJsx()
    ],
    resolve: {
      alias: {
        '@': `${resolve(__dirname, './')}`,
      }
    },
  },
  markdown: {
    config: (md: any) => plugin(md),
  },

  locales: {
    root: {
      label: '汉语',
      lang: 'zh-CN',
      themeConfig: {
        darkModeSwitchLabel: '外观',
        sidebarMenuLabel: '菜单',
        lastUpdatedText: '最后更新于',
        returnToTopLabel: '返回顶部',
        darkModeSwitchTitle: '暗黑模式',
        lightModeSwitchTitle: '亮模式',
        outlineTitle: '本页内容'
      }
    },
  }
})
